package com.qfmy.project.openApi.service.impl;

import com.qfmy.common.pojo.TokenVo;
import com.qfmy.core.pojo.entity.ErrorCode;
import com.qfmy.core.pojo.exception.CustomException;
import com.qfmy.project.openApi.service.LoginService;
import org.springframework.stereotype.Service;

/**
 * 描述:
 *      登录service的实现类
 * @author zhengjt
 * @date 2022-11-23 15:06:48
 */
@Service
public class LoginServiceImpl implements LoginService {

    @Override
    public TokenVo loginUser(String username, String password) throws CustomException {
        //  判断用户是否存在
        if ("testNeverUser".equals(username)){
            throw new CustomException(ErrorCode.NEVER_USER);
        }

        //  判断密码是否正确

        //  以下为测试使用信息，正式代码应当从数据库中获取，然后赋值给tokenVo对象
        TokenVo object = new TokenVo();
        object.setUserId("000001");
        object.setUserName(username);
        object.setUserNick("测试 - 开发者");
        object.setDeptId("000000001");
        object.setDeptName("测试部门");
        object.setCorpId("000000001");
        object.setCorpName("测试Corp");
        object.setOrgId("000000001");
        object.setOrgName("测试Org");

        return object;
    }
}
